﻿namespace PMS.Client.FrmUserLeave
{
    using PMS.BLL;
    using PMS.Client.Controls;
    using PMS.Client.FrmUser;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;
    using PMS.Model;

    public class FrmList : Form
    {
        private DataGridViewTextBoxColumn AdminPosition;
        private DataGridViewTextBoxColumn Birthday;
        private IContainer components;
        private UCDataGridView dataGridView1;
        private DataGridViewTextBoxColumn ID;
        private bool isLeave;
        private DataGridViewTextBoxColumn JobPositionName1;
        private DataGridViewTextBoxColumn JobPositionName2;
        private DataGridViewTextBoxColumn JobPositionType;
        private DataGridViewTextBoxColumn JobTitle;
        private Label lbTitle;
        private int OrganID;
        private DataGridViewTextBoxColumn RegistDate;
        private DataGridViewTextBoxColumn RegistTo;
        private DataGridViewTextBoxColumn RegistType;
        private DataGridViewTextBoxColumn RegistWay;
        private DataGridViewTextBoxColumn Sex;
        private UserBLL userBLL;
        private DataGridViewTextBoxColumn UserID;
        public List<User> UserList;
        private DataGridViewTextBoxColumn UserName;

        public FrmList(string keyWord)
        {
            this.components = null;
            this.userBLL = new UserBLL();
            this.OrganID = 0;
            this.isLeave = false;
            this.UserList = null;
            this.InitializeComponent();
            this.dataGridView1.AutoGenerateColumns = false;
            this.UserList = this.userBLL.GetList(0, null, keyWord);
            this.UserList = (this.UserList == null) ? new List<User>() : this.UserList;
            this.lbTitle.Text = string.Concat(new object[] { "搜索 \"", keyWord, "\" 结果  共", this.UserList.Count, "条记录" });
            this.dataGridView1.DataSource = this.UserList;
        }

        public FrmList(int OrganID, string OrganName, bool isLeave)
        {
            this.components = null;
            this.userBLL = new UserBLL();
            this.OrganID = 0;
            this.isLeave = false;
            this.UserList = null;
            this.InitializeComponent();
            this.OrganID = OrganID;
            this.isLeave = isLeave;
            this.lbTitle.Text = OrganName + " " + this.lbTitle.Text;
            this.dataGridView1.AutoGenerateColumns = false;
            this.UserList = this.userBLL.GetList(OrganID, new bool?(isLeave), "");
            this.dataGridView1.DataSource = this.UserList;
        }

        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            new FrmDetail(this.SelectedUserID).ShowDialog();
        }

        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            this.SelectedUserID = 0;
            if ((this.dataGridView1.SelectedRows.Count > 0) && (this.dataGridView1.SelectedRows[0].Cells["UserID"].Value != null))
            {
                this.SelectedUserID = int.Parse(this.dataGridView1.SelectedRows[0].Cells["UserID"].Value.ToString());
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void FrmList_Load(object sender, EventArgs e)
        {
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            DataGridViewCellStyle style2 = new DataGridViewCellStyle();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(PMS.Client.FrmUserLeave.FrmList));
            this.lbTitle = new Label();
            this.dataGridView1 = new UCDataGridView(this.components);
            this.UserID = new DataGridViewTextBoxColumn();
            this.UserName = new DataGridViewTextBoxColumn();
            this.Sex = new DataGridViewTextBoxColumn();
            this.RegistTo = new DataGridViewTextBoxColumn();
            this.ID = new DataGridViewTextBoxColumn();
            this.RegistType = new DataGridViewTextBoxColumn();
            this.JobPositionName1 = new DataGridViewTextBoxColumn();
            this.JobPositionName2 = new DataGridViewTextBoxColumn();
            this.JobPositionType = new DataGridViewTextBoxColumn();
            this.AdminPosition = new DataGridViewTextBoxColumn();
            this.Birthday = new DataGridViewTextBoxColumn();
            this.JobTitle = new DataGridViewTextBoxColumn();
            this.RegistWay = new DataGridViewTextBoxColumn();
            this.RegistDate = new DataGridViewTextBoxColumn();
            ((ISupportInitialize) this.dataGridView1).BeginInit();
            base.SuspendLayout();
            this.lbTitle.BackColor = Color.Gold;
            this.lbTitle.Dock = DockStyle.Top;
            this.lbTitle.Font = new Font("宋体", 14.25f, FontStyle.Bold, GraphicsUnit.Point, 0x86);
            this.lbTitle.ForeColor = Color.Black;
            this.lbTitle.Location = new Point(0, 0);
            this.lbTitle.Name = "lbTitle";
            this.lbTitle.Size = new Size(0x3b5, 0x1f);
            this.lbTitle.TabIndex = 10;
            this.lbTitle.Text = "减少人员列表";
            this.lbTitle.TextAlign = ContentAlignment.MiddleCenter;
            this.dataGridView1.AllowUserToAddRows = false;
            this.dataGridView1.AllowUserToDeleteRows = false;
            this.dataGridView1.AllowUserToResizeRows = false;
            this.dataGridView1.BackgroundColor = Color.FromArgb(0xa4, 0xc4, 0xeb);
            this.dataGridView1.BorderStyle = BorderStyle.None;
            this.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            this.dataGridView1.Columns.AddRange(new DataGridViewColumn[] { this.UserID, this.UserName, this.Sex, this.RegistTo, this.ID, this.RegistType, this.JobPositionName1, this.JobPositionName2, this.JobPositionType, this.AdminPosition, this.Birthday, this.JobTitle, this.RegistWay, this.RegistDate });
            style.Alignment = DataGridViewContentAlignment.MiddleLeft;
            style.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            style.Font = new Font("宋体", 9f);
            style.ForeColor = Color.Black;
            style.SelectionBackColor = SystemColors.Highlight;
            style.SelectionForeColor = Color.Black;
            style.WrapMode = DataGridViewTriState.True;
            this.dataGridView1.DefaultCellStyle = style;
            this.dataGridView1.Dock = DockStyle.Fill;
            this.dataGridView1.GridColor = Color.FromArgb(0xd0, 0xd7, 0xe5);
            this.dataGridView1.HighlightSelectedColumnHeaders = false;
            this.dataGridView1.Location = new Point(0, 0x1f);
            this.dataGridView1.MultiSelect = false;
            this.dataGridView1.Name = "dataGridView1";
            this.dataGridView1.ReadOnly = true;
            this.dataGridView1.RowTemplate.Height = 0x17;
            this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            this.dataGridView1.Size = new Size(0x3b5, 0x1ba);
            this.dataGridView1.TabIndex = 11;
            this.dataGridView1.SelectionChanged += new EventHandler(this.dataGridView1_SelectionChanged);
            this.dataGridView1.DoubleClick += new EventHandler(this.dataGridView1_DoubleClick);
            this.UserID.DataPropertyName = "UserID";
            style2.Alignment = DataGridViewContentAlignment.MiddleCenter;
            style2.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.UserID.DefaultCellStyle = style2;
            this.UserID.HeaderText = "ID";
            this.UserID.Name = "UserID";
            this.UserID.ReadOnly = true;
            this.UserID.Visible = false;
            this.UserID.Width = 30;
            this.UserName.DataPropertyName = "UserName";
            this.UserName.HeaderText = "姓名";
            this.UserName.Name = "UserName";
            this.UserName.ReadOnly = true;
            this.Sex.DataPropertyName = "Sex";
            this.Sex.HeaderText = "性别";
            this.Sex.Name = "Sex";
            this.Sex.ReadOnly = true;
            this.Sex.Width = 50;
            this.RegistTo.DataPropertyName = "RegistTo";
            this.RegistTo.HeaderText = "所在机构";
            this.RegistTo.Name = "RegistTo";
            this.RegistTo.ReadOnly = true;
            this.RegistTo.Width = 150;
            this.ID.DataPropertyName = "ID";
            this.ID.HeaderText = "身份证号";
            this.ID.Name = "ID";
            this.ID.ReadOnly = true;
            this.ID.Width = 120;
            this.RegistType.DataPropertyName = "RegistType";
            this.RegistType.HeaderText = "编制类别";
            this.RegistType.Name = "RegistType";
            this.RegistType.ReadOnly = true;
            this.JobPositionName1.DataPropertyName = "JobPositionName1";
            this.JobPositionName1.HeaderText = "职务1";
            this.JobPositionName1.Name = "JobPositionName1";
            this.JobPositionName1.ReadOnly = true;
            this.JobPositionName2.DataPropertyName = "JobPositionName2";
            this.JobPositionName2.HeaderText = "职务2";
            this.JobPositionName2.Name = "JobPositionName2";
            this.JobPositionName2.ReadOnly = true;
            this.JobPositionType.DataPropertyName = "JobPositionType";
            this.JobPositionType.HeaderText = "职务类型";
            this.JobPositionType.Name = "JobPositionType";
            this.JobPositionType.ReadOnly = true;
            this.AdminPosition.DataPropertyName = "AdminPosition";
            this.AdminPosition.HeaderText = "行政职务";
            this.AdminPosition.Name = "AdminPosition";
            this.AdminPosition.ReadOnly = true;
            this.Birthday.DataPropertyName = "Birthday";
            this.Birthday.HeaderText = "出生日期";
            this.Birthday.Name = "Birthday";
            this.Birthday.ReadOnly = true;
            this.JobTitle.DataPropertyName = "JobTitle";
            this.JobTitle.HeaderText = "职称";
            this.JobTitle.Name = "JobTitle";
            this.JobTitle.ReadOnly = true;
            this.RegistWay.DataPropertyName = "RegistWay";
            this.RegistWay.HeaderText = "进入单位形式";
            this.RegistWay.Name = "RegistWay";
            this.RegistWay.ReadOnly = true;
            this.RegistWay.Width = 120;
            this.RegistDate.DataPropertyName = "RegistDate";
            this.RegistDate.HeaderText = "进入单位时间";
            this.RegistDate.Name = "RegistDate";
            this.RegistDate.ReadOnly = true;
            this.RegistDate.Width = 120;
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x3b5, 0x1d9);
            base.Controls.Add(this.dataGridView1);
            base.Controls.Add(this.lbTitle);
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.Name = "FrmList";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "实有人员列表";
            base.Load += new EventHandler(this.FrmList_Load);
            ((ISupportInitialize) this.dataGridView1).EndInit();
            base.ResumeLayout(false);
        }

        public int SelectedUserID { get; set; }
    }
}

